package com._520it.crm.service.impl;

import com._520it.crm.domain.FollowupBill;
import com._520it.crm.mapper.FollowupBillMapper;
import com._520it.crm.page.PageResult;
import com._520it.crm.query.FollowupBillQueryObject;
import com._520it.crm.service.IFollowupBillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.Date;
import java.util.List;

/**
 * Created by Administrator on 2017/10/11.
 */
@Service
public class FollowupBillServiceImpl implements IFollowupBillService {
    @Autowired
    private FollowupBillMapper followupBillMapper;

    @Override
    public int deleteByPrimaryKey(Long id) {
        return followupBillMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(FollowupBill record) {
        record.setFollowtime(new Date());
        return followupBillMapper.insert(record);
    }

    @Override
    public FollowupBill selectByPrimaryKey(Long id) {
        return followupBillMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<FollowupBill> selectAll() {
        return followupBillMapper.selectAll();
    }

    @Override
    public int updateByPrimaryKey(FollowupBill record) {
        return followupBillMapper.updateByPrimaryKey(record);
    }

    @Override
    public PageResult queryPage(FollowupBillQueryObject qo) {
        Long count = followupBillMapper.queryPageCount(qo);
        if (count <= 0) {
            return new PageResult(0L, Collections.EMPTY_LIST);
        }
        List<FollowupBill> result = followupBillMapper.queryPageDataResult(qo);
        PageResult pageResult = new PageResult(count, result);
        return pageResult;
    }
}
